<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" th:href="@{/material/素材/logo/32.png}" type="image/png">
    <title>登陆</title>
    <link th:href="@{/static/assets/plugins/sweetalert/sweetalert.css}" rel="stylesheet"/>
    <link th:href="@{/static/assets/css/icons.css}" rel="stylesheet">
    <link th:href="@{/static/assets/css/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/static/assets/css/style.css}" rel="stylesheet">
    <link th:href="@{/static/assets/css/responsive.css}" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.min.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->

</head>

<body class="sticky-header">


<!--Start login Section-->
<section class="login-section">
    <div class="container">
        <div class="row">
            <div class="login-wrapper">
                <div class="login-inner">

                    <div class="logo">
                        <img th:src="@{/static/assets/images/logo-dark.png}" height="33px" width="50px" alt="logo"/>
                        Fly67 初品 - 登陆
                    </div>

                    <h2 class="header-title text-center">登陆</h2>

                    <form name="form" id="form" onsubmit="return false" action="#">
                        <div class="form-group">
                            <input type="text" class="form-control" id="username" name="username" placeholder="用戶名" required>
                        </div>

                        <div class="form-group">
                            <input type="password" class="form-control" id="password" name="password" placeholder="密碼" required>
                        </div>

                        <div class="form-group">
                            <div class="pull-left">
                                <div class="checkbox primary">
                                    <input id="checkbox-2" type="checkbox">
                                    <label for="checkbox-2">Remember me</label>
                                </div>
                            </div>

                            <div class="pull-right">
                                <a th:href="reset-password.html" class="a-link">
                                    <i class="fa fa-unlock-alt"></i> 忘记密码
                                </a>
                            </div>
                        </div>

                        <div class="form-group">
                            <input type="button" value="登陆" class="btn btn-primary btn-block" onclick="login();return false;"/>
                            <a href="/login/feishuLoginPage" class="btn btn-primary btn-block">飞书登陆</a>
                        </div>

                    </form>

                    <div class="copy-text">
                        <p class="m-0">2021 &copy; Fly67 初品</p>
                    </div>

                </div>
            </div>

        </div>
    </div>
</section>
<!--End login Section-->


<!--Begin core plugin -->
<script th:src="@{/static/assets/js/jquery.min.js}"></script>
<script th:src="@{/static/assets/js/bootstrap.min.js}"></script>
<!-- End core plugin -->

<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script th:src="@{/assets/plugins/sweetalert/sweet-alert.js}"></script>
<script th:src="@{/assets/pages/jquery.sweet-alert.custom.js}"></script>
<!-- BEGIN PAGE LEVEL SCRIPTS -->


<script>
    function submit1() {
        console.log('登陆提交');
        var username = $("#username").val();
        var password = $("#password").val();
        $.post("/login", {"username": username, "password": password}, function (data, status) {
            swal(data);
        });
    }

    function login() {
        console.log('登陆提交');
        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/login/" ,//url
            data: $('#form').serialize(),
            success: function (result) {
                console.log(result);//打印服务端返回的数据(调试用)
                if (result.code != 200) {
                   alert(result.msg)
                } else {
                    // 登陆成功
                    window.location.href='/profile';
                }

            },
            error : function(result) {
                console.log(result.responseJSON);//打印服务端返回的数据(调试用)
                alert(result.responseJSON.msg);
            }
        });
    }


    $(function () {

    })
</script>

</body>

</html>
